{% extends "rest_base.html" %}
{% block rest_script %}
	function createCart() {
		function createRest(rest_alias,rest_name){
			order = $('<a title="菜还不够？那就继续点餐吧！"></a>').attr("href", "/rest/"+rest_alias+"/dish/").text(rest_name);
			return $('<div class="order_dish_res"></div>').append(order);
		}
		
		function createTotalCard(dish_count, total) {
	        dc = $('<span class="dish_total">总共： <span class="red2">' + dish_count + '</span>份</span>');
			tt = $('<span>总金额：<span class="red2">' + total + '</span> 元</span>');
	        return $('<div class="dish_list_countTtotal"></div>').append(dc).append(tt);
		}
		
		
		
		m = $('<ol id="floatMenu_dish_list"></ol>');
		menu_content = $('<div class="floatMenu_content" style="display:none;"></div>').append(m).
			append('<a href="/order/confirm/asdf/ class="float_menu_dish_confirm" title="菜点好了吗？去确认一下吧！"></a>');			
		
		cart = $('#cart').append(createRest("hao","东莞好事大酒店")).append(createTotalCard(0,0)).append(menu_content);
		return m;
	}
	function createCartItem(id, name, price ,mount){
		return $('<li><a href="" class="dish_lish_name">' + name + '</a>' +
	       '<span class="order_dish_count_cut"></span>' +
	       '<input name="amount" type="text" value="' + mount + '">' + 
		   '<span class="order_dish_count_add"></span>' + 
	       '<span class="dish_alone_pri">' + price + '元</span>' + 
		   '<span class="dish_cut" rel="' + id + '">删除</span></li>');
	
	}
	$(".addToMenu").click(function(e){
		e.preventDefault();
		dishid = $(this).attr("href");
		restid = $(this).attr("rel");
		url = '/order/dish/add/';
		data = {"restid":restid ,"dishid": dishid };
		$.post(url, data, function(result){
			window.location.href = window.location.href;
		});
	});
{% endblock %}
{% block left_content %}
          <div class="dish_menu">
             
             <div class="res_alone_name">菜式分类</div>
           <ul>
             {% for ct in rest.rest_cuis_type_set.all%}
              <li><a href="">{{ct.name}}</a></li>
              {% endfor %}
           </ul>
           </div>
{% endblock %}
{% block right_content %}
             <div class="res_right_title">菜式 > 所有</div>             
             <ul class="res_dish">
             	{% for d in dishs %}
                 <li>
                     <img src="/image/{{d.img}}" width="140" height="140">
                     <ul class="name_prise">
                       <li class="dish_name">{{d.name}}</li>
                       <li><span class="prise">￥{{d.price}}/例</span><a class="addToMenu" href="{{d.id}}" rel="{{rest.id}}">加入菜单</a></li>
                     </ul>   
                 </li>
                 {% endfor %}
             </ul>
             <div class="clear"></div>
             <div class="count">
             <a href="">首页</a>
             <a href="">上一页</a>
             <a href="">1</a>
             <a href="">2</a>
             <a href="">3</a>
             <a href="">下一页</a>
             <a href="">末页</a>
             </div>     
{% endblock %}
